import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Mock using CJS

You can use your favorite **Mock** framework or tool and **Poku** together 🐷➕

> By not locking you into a specific set of plugins or mocking/spying tools, **Poku** promotes an open ecosystem where developers are free to integrate the tools that best suit their needs.

For this example, let's use the [**quibble**](https://github.com/testdouble/quibble), then testing its results with **Poku**:

<Tabs>
  <TabItem default value='./test/withdraw.test.js'>

    ```js
    const { assert } = require('poku');
    const quibble = require('quibble');

    (async () => {
      await quibble('../lib/funds.js', {
        // Original: 100
        getFunds: () => 200,
      });

      const { withdraw } = require('../lib/withdraw.js');

      assert.strictEqual(withdraw(200), true, 'Mocking my funds to 200');

      assert.strictEqual(withdraw(300), false, "I can't get more than I have");

      await quibble.reset();
    })();
    ```

  </TabItem>
  <TabItem  value='./lib/funds.js'>

    ```js
    const getFunds = () => 100;

    module.exports = { getFunds };
    ```

  </TabItem>
  <TabItem  value='./lib/withdraw.js'>

    ```js
    const { getFunds } = require('./funds.js');

    const withdraw = (value) => {
      const wallet = getFunds();

      return value <= wallet;
    };

    module.exports = { withdraw };
    ```

  </TabItem>
</Tabs>

Then:

```bash
npx poku
```
